Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(expect): objectContaining traversing non vanilla Objects #10720

Closed
wants to merge 2 commits into from
Closed

fix(expect): objectContaining traversing non vanilla Objects #10720

wants to merge 2 commits into from

Conversation

scagood
Copy link

@scagood scagood commented Oct 26, 2020

Attempting to fix the bug found in #10716

Summary

This change will change objectContaining to only recursively step into vanilla sub-objects

Test Plan

Added new test cases to cover this behaviour

@facebook-github-bot
Copy link
Contributor

Hi @scagood!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you add a changelog entry?

@SimenB SimenB requested a review from jeysal October 26, 2020 20:27
@SimenB SimenB linked an issue Oct 26, 2020 that may be closed by this pull request
this.sample[property],
);
if (
samplePropertyPrototype === Object.prototype ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might break for cases hit by #2549, but 🤞 it does not

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does break, afaik the next best ways to check for "plain objects" are Object.getPrototypeOf(sample)?.constructor?.name === 'Object' and Object.prototype.toString.call(sample) .... These are imprecise, but at least they work across realms.

Array.isArray() could be substituted for the Array.prototype check to fix that case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I can confirm that this is broken for cross-realm inputs, like in #2549. ninevra@0553005 adds a failing test on top of this PR to demonstrate the issue.

@jeysal
Copy link
Contributor

jeysal commented Oct 26, 2020

Honestly, with #10508 in, is this still any different from what toMatchObject does? I think it's the same now? In that case, this asymmetric matchers is just a matter of

const pass = equals(received, expected, [iterableEquality, subsetEquality]);

Does that pass the tests?

@scagood
Copy link
Author

scagood commented Oct 27, 2020

I am unable to get the correct people to sign the CLA, therefore I can only close this PR. I am sorry.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toHaveBeenCalledWith objectContaining issue after patch update 26.6.1
5 participants